<%--
    Document   : validation
    Created on : 27 mai 2012, 12:56:54
    Author     : Thomas
--%>

<%@include file="_header.jsp" %>
<%@include file="_left.jsp" %>

<%! String error_msg; %>
<% error_msg = (String)request.getAttribute("error_msg"); %>

<%! Customer customer; %>
<% customer = (Customer) request.getSession().getAttribute("customer"); %>

<%! BasketMgr panier; %>
<% panier = (BasketMgr) request.getSession().getAttribute("basket"); %>

<div class="span7">
<% if (error_msg != null) { %>
    <h3>Oups !</h3>
    <br/>
    <div class="alert-error"><strong><%= error_msg %></strong></div>
    <hr/>
    <div class="row-fluid">
        <div class="pull-right">
            <a class="btn btn-primary" href="<%= request.getContextPath() %>/Order?action=validerCommande">OK</a>
        </div>
    </div>
<% } else { %>
    <h3>Ma commande : r&eacute;sum&eacute; (&eacute;tape 4/5)</h3>
    <br/>
    <p>
        <em>Votre commande est pr&ecirc;te &agrave; &ecirc;tre envoy&eacute;e. Merci de v&eacute;rifier une derni&egrave;re fois les informations fournies.</em>
    </p>
    <br/>
    <div class="row-fluid">
        <div class="span6">
            <h4>Client</h4>
            <br/>
            <address>
                <%= customer.getFirstName() %>&nbsp;<%= customer.getLastName().toUpperCase() %><br/>
                <%= customer.getEmail() %><br/>
                <abbr title="T&eacute;l&eacute;phone">T&eacute;l.:&nbsp;</abbr><%= customer.getNumTel() %>
            </address>
        </div>
        <div class="span6">
            <h4>Adresse</h4>
            <br/>
            <address>
                <%= customer.getFirstName() %>&nbsp;<%= customer.getLastName().toUpperCase() %><br/>
                <%= customer.getAddress().getLine1() %><br/>
                <% if(customer.getAddress().getLine2().length() > 0) {out.println(customer.getAddress().getLine2() + "<br/>");} %>
                <%= customer.getAddress().getZipCode() %>&nbsp;<%= customer.getAddress().getCity() %>&nbsp;(<%= customer.getAddress().getCountry() %>)
            </address>
        </div>
    </div>
    <br/>
    <h4>Commande</h4>
    <br/>
    <table class="table">
        <thead>
            <tr>
                <th>Produit</th>
                <th>Prix</th>
            </tr>
        </thead>
        <tbody>
        <% for(Product product : panier.getProducts()) {%>
            <tr>
                <td><%= product.getName() %></td>
                <td style="text-align: right;"><%= product.getPrice() %>&nbsp;&euro;</td>
            </tr>
        <% }%>
            <tr>
                <td><strong>Total TTC</strong></td>
                <td style="text-align: right;"><strong><%= panier.getTotal() %>&nbsp;&euro;</strong></td>
            </tr>
        </tbody>
    </table>
    <hr/>
    <div class="row-fluid">
        <form class="form-horizontal" method="post" action="<%= request.getContextPath() %>/Order?action=envoyerCommande">
            <div class="pull-left">
                <input type="submit" class="btn btn-danger" name="cancel" value="annuler"/>
            </div>
            <div class="pull-right">
                <input type="submit" class="btn" name="previous" value="&larr;&nbsp;article"/>
                <input type="submit" class="btn btn-primary" name="next" value="envoyer&nbsp;&rarr;"/>
            </div>
        </form>
    </div>
<% } %>
</div>

<%@include file="_right.jsp" %>
<%@include file="_footer.jsp" %>